package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author fx
 * @since 2024-08-27
 */
@Api(tags = "点赞相关接口")
@RestController
@RequestMapping("/likes")
@RequiredArgsConstructor
public class LikedRecordController {
    private final ILikedRecordService likedRecordService;

    /**
     * 01 点赞或者取消点赞（day06-随堂-01）
     *
     * @param formDTO
     */
    @ApiOperation("点赞或者取消点赞")
    @PostMapping
    public void LikeOrUnlike(@Valid @RequestBody LikeRecordFormDTO formDTO) {
        likedRecordService.LikeOrUnlike(formDTO);
    }

    /**
     * 02 根据业务id集合查询点赞状态（day06-随堂-02）
     * 查询当前用户是否已经点赞
     *
     * @param bizIds
     * @return
     */
    @ApiOperation("查询点赞状态")
    @GetMapping("/list")
    public Set<Long> isLiked(@RequestParam("bizIds") List<Long> bizIds) {
        return likedRecordService.isliked(bizIds);
    }

}
